#include "Geters.h"

DatabaseModule::SmartQuery smartQuery;

DatabaseModule::QueryModelPtr DatabaseModule::getAnimeList(int amask) {
	QStringList selectFields;
	QStringList animeFields;

	animeFields << "aid"
		<< "image"
		<< "romaji_name"
		<< "kanji_name"
		<< "eng_name"
		<< "is_ongoing"
		<< "adb_anime_types.name"
		<< "normal_ep_count"
		<< "special_ep_count"
		<< "anidb_rating"
		<< "own_rating"
		<< "air_date"
		<< "end_date";

	for (int i = 0; i < animeFields.size(); ++i)
		if ((amask >> i) & 1)
			if (i != animeFields.indexOf("adb_anime_types.name"))
				selectFields.push_back("adb_anime." + animeFields.at(i));
			else
				selectFields.push_back(animeFields.at(i));

	smartQuery.setFieldList(selectFields);

	qDebug() << smartQuery.generateSqlQuery();

	return smartQuery.exec();
}